package com.jqq.homework;

import java.util.ArrayList;
import java.util.Iterator;

/**
 * @author 姬倩倩
 * @version 1.0
 */
@SuppressWarnings({"all"})
public class Homework02 {
    public static void main(String[] args) {
        Car car = new Car("宝马", 400000);
        Car car2 = new Car("宾利", 5000000);
        ArrayList list = new ArrayList();
        list.add(car);
        list.add(car2);
        list.remove(car2);
        System.out.println(list.contains(car));
        System.out.println(list.size());
        System.out.println(list.isEmpty());
        list.clear();
        ArrayList list1 = new ArrayList();
        list1.add(car);
        list1.add(car2);
        list.addAll(list1);
        System.out.println(list);
        list.contains(list1);
        list.removeAll(list1);
        list.addAll(list1);
        for (Object o :list) {
            Car car_ = (Car)o;
            System.out.println(car_);
        }
        Iterator iterator = list.iterator();
        while (iterator.hasNext()) {
            Object o =  iterator.next();
            System.out.println(o);
        }
    }
}
class Car{
    private String name;
    private double price;

    public Car(String name, double price) {
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Car{" +
                "name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}